package org.xiaojinlong.reading;

import java.net.*;
import java.util.Enumeration;

/**
 * Created by jinlong on 2015/2/12.
 */
public class TT {
    public static void main(String[] args) throws SocketException, UnknownHostException {
        InetAddress[] addr = InetAddress.getAllByName("taobao.com");
        for (InetAddress address : addr) {
            System.out.format("\t%s/%s", address.getHostName(), address.getHostAddress());
        }
//        Enumeration<NetworkInterface> interfaceEnumeration = NetworkInterface.getNetworkInterfaces();
//        if (interfaceEnumeration == null)
//            System.out1.println("--没有网络接口--");
//        else
//            while (interfaceEnumeration.hasMoreElements()) {
//                NetworkInterface iface = interfaceEnumeration.nextElement();
//                System.out1.println("Interface [" + iface.getName() + "][" + iface.getDisplayName() + "]:");
//                Enumeration<InetAddress> addressEnumeration = iface.getInetAddresses();
//                if (!addressEnumeration.hasMoreElements())
//                    System.out1.println("\t(No addresses for this interface");
//                while (addressEnumeration.hasMoreElements()) {
//                    InetAddress address = addressEnumeration.nextElement();
//                    System.out1.print("\tAddress "
//                        + ((address instanceof Inet4Address ? "(v4)"
//                            : (address instanceof Inet6Address ? "(v6)" : "(?)"))));
//                    System.out1.println(": [" + address.getHostAddress() + "]");
//                }
//            }
    }
}
